﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

public partial class cms_Admin_Danhgia_u_Xemdanhgiacanhan : System.Web.UI.UserControl
{
    string uID = "";
    #region[Page_Load]
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["uid"] != null) { uID = Session["uid"].ToString(); }
        if (!IsPostBack) { ViewAsslist(); }
    }
    #endregion
    #region[ViewAsslist]
    void ViewAsslist()
    {
        List<tbAssessmentDATA> list = tbAssessmentDB.tbAssessment_GetByuID(uID);
        rptDanhsach.DataSource = list;
        rptDanhsach.DataBind();
        for (int i = 0; i < list.Count; i++)
        {
            Label lblorder = (Label)rptDanhsach.Items[i].FindControl("lblorder");
            int k = (i + 1);
            lblorder.Text = k.ToString();
        }
        list.Clear();
        list = null;
    }
    void ViewAsslist_Asc()
    {
        List<tbAssessmentDATA> list = tbAssessmentDB.tbAssessment_GetByuID_Asc(uID);
        rptDanhsach.DataSource = list;
        rptDanhsach.DataBind();
        for (int i = 0; i < list.Count; i++)
        {
            Label lblorder = (Label)rptDanhsach.Items[i].FindControl("lblorder");
            int k = (i + 1);
            lblorder.Text = k.ToString();
        }
        list.Clear();
        list = null;
    }
    #endregion
    #region[FormatDate]
    protected string FormatDate(DateTime date)
    {
        try
        {
            if (date.ToString().Trim().Length > 0)
            {
                if (DateTime.Parse(date.ToString()).Year != 1900)
                {
                    string Chuoi = "Tháng " + date.Month.ToString();
                    return Chuoi;
                    //return ((DateTime)date).ToString("dd/MM/yyyy");
                }
                else
                {
                    return "";
                }
            }
            else
            {
                return "";
            }
        }
        catch { return date.ToString(); }
    }
    protected string FormatDateHH(DateTime date)
    {
        try
        {
            if (date.ToString().Trim().Length > 0)
            {
                if (DateTime.Parse(date.ToString()).Year != 1900)
                {
                    return ((DateTime)date).ToString("dd/MM/yyyy hh:mm:ss");
                }
                else
                {
                    return "";
                }
            }
            else
            {
                return "";
            }
        }
        catch { return date.ToString(); }
    }
    #endregion
    #region[rptDanhsach_ItemCommand]
    protected void rptDanhsach_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        string mainID = "";
        string ten = e.CommandName.ToString();
        mainID = e.CommandArgument.ToString();
        switch (ten)
        {
            case "View":
                List<tbAssessmentDetailDATA> list = tbAssessmentDetailDB.tbAssessmentDetail_GetByassId(mainID);
                rptSub.DataSource = list;
                rptSub.DataBind();
                for (int i = 0; i < list.Count; i++)
                {
                    Label lblorder = (Label)rptSub.Items[i].FindControl("lblorder");
                    int k = (i + 1);
                    lblorder.Text = k.ToString();
                }
                list.Clear();
                list = null;
                List<tbAssessmentDATA> listm = tbAssessmentDB.tbAssessment_GetByID(mainID);
                rptDanhsach.DataSource = listm;
                rptDanhsach.DataBind();
                for (int j = 0; j < listm.Count; j++)
                {
                    Label lblorder = (Label)rptDanhsach.Items[j].FindControl("lblorder");
                    int k = (j + 1);
                    lblorder.Text = k.ToString();
                }
                listm.Clear();
                listm = null;
                pnUpdate.Visible = true;
                break;
        }
    }
    #endregion
    #region[Back]
    protected void lbtTrolai_Click(object sender, EventArgs e)
    {
        ViewAsslist();
        pnUpdate.Visible = false;
    }
    #endregion
    #region[SortAsc]
    protected void lbtTang_Click(object sender, EventArgs e)
    {
        ViewAsslist_Asc();
    }
    #endregion
    #region[SortDesc]
    protected void lbtGiam_Click(object sender, EventArgs e)
    {
        ViewAsslist();
    }
    #endregion
}
